using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using BILab.Technical.BI.Facade;
using Microsoft.AnalysisServices.AdomdClient;

namespace MdGridViewTester
{
    public partial class Form1 : Form
    {
       
        #region Constant and fields
        private const string C_CONNECTIONSTRING = @"Provider=MSOLAP.3;Cache Authentication=False;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Analysis Services Tutorial;Data Source=.\BILAB;Impersonation Level=Impersonate;Mode=ReadWrite;Auto Synch Period=20000;Default Isolation Mode=0;Default MDX Visual Mode=0;MDX Compatibility=0;MDX Unique Name Style=0;Non Empty Threshold=0;SQLQueryMode=Calculated;Safety Options=1;Secured Cell Value=0;SQL Compatibility=0;Compression Level=0;Real Time Olap=False;Packet Size=4096";
        //private const string C_MDXQUERY = @"select { [Date].[Fiscal Time].[Fiscal Year].Members } on columns,NonEmptyCrossJoin([Promotion].[Promotions].[Promotion Category].Members,[Product].[Product Categories].[Category].Members) on rows from [Analysis Services Tutorial]";
        //private const string C_MDXQUERY = @"select 	CrossJoin( [Date].[Fiscal Time].[Fiscal Year].Members, {[Measures].[Internet Sales-Sales Amount],[Measures].[Internet Sales-Order Quantity]} ) on columns,	NonEmptyCrossJoin([Promotion].[Promotions].[Promotion Category].Members,[Product].[Product Categories].[Category].Members) on rows from [Analysis Services Tutorial]";
        private const string C_MDXQUERY = @"select 	NonEmptyCrossJoin( [Date].[Fiscal Time].[Fiscal Year].Members, {[Measures].[Internet Sales-Sales Amount],[Measures].[Internet Sales-Order Quantity]} ) on columns,NonEmptyCrossJoin([Promotion].[Promotions].[Promotion Category].Members,	CrossJoin(		[Reseller].[Reseller Type].[Business Type].Members,		[Product].[Product Categories].[Category].Members	)	) on rows from [Analysis Services Tutorial]";
        private BILab.Technical.BI.Facade.MultidimensionalFacade _mdFacade = new MultidimensionalFacade();
        #endregion

        public Form1()
        {
            InitializeComponent();
            _mdFacade.Connect(C_CONNECTIONSTRING);
            CellSet cset = _mdFacade.getCellSet(C_MDXQUERY);
            MdgCube.HeaderBackground = Color.SteelBlue;
            MdgCube.HeaderForeground = Color.White;
            MdgCube.DisplayCellSetHierarchy(cset);
            _mdFacade.Close();
        }
    }
}